<%@page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%@ page isELIgnored="false"%>
<%
	String path = request.getContextPath();
	System.out.print(path);
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
	System.out.print(basePath);
%>
<html>
<head>
<base href="<%=basePath%>">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>TI - dbConfig</title>
<link rel="icon" href="images/favicon.ico" type="image/x-icon" />
<script src="js/jquery.js"></script>
<link rel="stylesheet" href="css/bootstrap.min.css">
<script src="js/bootstrap.min.js"></script>
<title>Insert title here</title>
<script type="text/javascript">
	function deleteTaskInfo(o) {
		if (window.confirm("确认删除?"))
			window.location.href = "deleteTaskInfo.action?id=" + o.id;
	}
	function clickModal(o){
		$.ajax({
			type : "POST",
			url : "getLastTaskInfo.action?taskId="+o.id,
			data : "",
			async : false,
			cache : false,
			success : function(json) {
				var lti = jQuery.parseJSON(json);
				$("#d_taskName").val(lti.taskName);
				$("#d_timeConfig").val(lti.timeConfig);
				$("#d_lastBatchNumber").val(lti.lastBatchNumber);
				$("#d_startTime").val(lti.lastRunTime);
				$("#d_mailTo").val(lti.mailTo);
				$("#d_description").val(lti.description);
				$("#d_contains").val(lti.contains);
			},
			error : function(e) {
				alert("对不起，后台处理发生异常，请联系管理员!");
			}
		});
		$("#modal-504349").click();
	}
	$(document).ready(function() {
		$("#taskInfoSubmit").click(function() {
			$("#taskInfoForm").submit();
		});
		$("#checkbox_p").click(function() {
			var arrSon = $("input[name='checkbox_s']");
			var temp = $("#checkbox_p").is(':checked');
			for (var i = 0; i < arrSon.length; i++) {
				if (temp)
					arrSon[i].checked = true;
				else
					arrSon[i].checked = false;
			}
		});
		$("#taskAddBtn").click(function() {
			var str = "";
			var arrSon = $("input[name='checkbox_s']");
			var tempInt = 0;
			for (var i = 0; i < arrSon.length; i++) {
				if (arrSon[i].checked && tempInt == 0) {
					str += arrSon[i].id;
					tempInt++;
					continue;
				}
				if (arrSon[i].checked)
					str += "," + arrSon[i].id;
			}
			$("#contains").empty();
			$("#contains").val(str);
			if (str == "") {
				alert("请选择需要执行的用例!");
				return;
			}
		});
	});
</script>
</head>
<body>
	<div class="row clearfix">
		<div class="col-md-8 column">
			<h4>
				<em class="glyphicon glyphicon-subtitles"></em> 用例批量选择配置
			</h4>
			<form role="form" class="form-inline">
				<div class="form-group">
					<label for="exampleInputEmail1">用例名称:</label><input type="email"
						class="form-control" id="exampleInputEmail1" />
				</div>
				<div class="form-group">
					<label for="exampleInputPassword1">类型</label><input type="password"
						class="form-control" id="exampleInputPassword1" />
				</div>
				<div class="form-group">
					<label for="exampleInputPassword1">级别</label><input type="password"
						class="form-control" id="exampleInputPassword1" />
				</div>
				<!-- <div class="form-group">
					<label for="exampleInputEmail1">创建时间:</label><input type="email"
						class="form-control" id="exampleInputEmail1" /> - <input
						type="email" class="form-control" id="exampleInputEmail1" />
				</div> -->
				<button type="submit" class="btn btn-primary">查询</button>
				<a id="taskAddBtn" href="#modal-container-734159" role="button"
					class="btn btn-primary btn-default" data-toggle="modal">增加TASK<em
					class="glyphicon glyphicon-plus-sign"></em></a>
			</form>
			<!-- <div class="pull-right"> -->
			<!-- </div> -->
			<div class="modal fade" id="modal-container-734159" role="dialog"
				aria-labelledby="myModalLabel" aria-hidden="true"
				data-backdrop="static">
				<div class="modal-dialog">
					<div class="modal-content">
						<div class="modal-header">
							<button type="button" class="close" data-dismiss="modal"
								aria-hidden="true">×</button>
							<h4 class="modal-title" id="myModalLabel">运行TASK增加</h4>
						</div>
						<div class="modal-body">
							<form class="form-horizontal" role="form" id="taskInfoForm"
								action="saveTaskInfo.action" methdo="POST">
								<div class="form-group">
									<label for="inputEmail3" class="col-sm-3 control-label">TASK名称</label>
									<div class="col-sm-8">
										<input class="form-control" id="inputEmail3" type="email"
											name="ti.taskName" />
									</div>
								</div>
								<div class="form-group">
									<label for="inputEmail3" class="col-sm-3 control-label">时间配置</label>
									<div class="col-sm-6">
										<input class="form-control" id="inputEmail3" type="email"
											name="ti.timeConfig" />
									</div>
								</div>
								<div class="form-group">
									<label for="inputPassword3" class="col-sm-3 control-label">邮件发送</label>
									<div class="col-sm-8">
										<textarea class="form-control" rows="3" name="ti.mailTo"></textarea>
									</div>
								</div>
								<div class="form-group">
									<label for="inputPassword3" class="col-sm-3 control-label">描述</label>
									<div class="col-sm-8">
										<textarea class="form-control" rows="3" name="ti.description"></textarea>
									</div>
								</div>
								<div class="form-group">
									<label for="inputPassword3" class="col-sm-3 control-label">包含用例</label>
									<div class="col-sm-8">
										<textarea class="form-control" rows="3" name="ti.contains"
											id="contains" spellcheck="false" readonly="readonly"></textarea>
									</div>
								</div>
						</div>
						<div class="modal-footer">
							<button type="reset" class="btn btn-default">重置</button>
							<button type="submit" class="btn btn-primary" id="taskInfoSubmit"
								data-dismiss="modal">提交</button>
						</div>
						</form>
					</div>

				</div>

			</div>
			<div style="float: left; width: 100%; height: 80%; overflow: auto;">
				<table class="table table-striped table-hover table-condensed">
					<thead>
						<tr>
							<th><input type="checkbox" id="checkbox_p" /></th>
							<th>编号</th>
							<th>名称</th>
							<th>类型</th>
							<th>级别</th>
							<th>创建时间</th>
							<th>创建人</th>
						</tr>
					</thead>
					<tbody>
						<s:iterator value="cil" var="caseInfo">
							<tr>
								<th><s:checkbox theme="simple" id="%{#caseInfo.id}"
										name="checkbox_s" class="checkbox_s" /></th>
								<th>interface-<s:property value="#caseInfo.id" /></th>
								<th><s:property value="#caseInfo.name" /></th>
								<th><s:property value="#caseInfo.type" /></th>
								<th><s:property value="#caseInfo.level" /></th>
								<th><s:property value="#caseInfo.createDate" /></th>
								<th><s:property value="#caseInfo.owner" /></th>
							</tr>
						</s:iterator>
					</tbody>
				</table>
			</div>
		</div>
		<div class="col-md-4 column">
			<h4>
				<em class="glyphicon glyphicon-subtitles"></em> TASK运行配置
			</h4>
			<div style="float: left; width: 100%; height: 80%; overflow: auto;">
				<table class="table table-striped table-hover table-condensed" id="taskTable">
					<thead>
						<tr>
							<th>编号</th>
							<th>TASK名称</th>
							<th>时间配置</th>
							<th>创建人</th>
							<th>操作</th>
						</tr>
					</thead>
					<tbody id="taskTableBody">
						<s:iterator value="til" var="taskInfo">
							<tr>
								<td>task-<s:property value="#taskInfo.id" /></td>
								<td><s:property value="#taskInfo.taskName" /></td>
								<td><s:property value="#taskInfo.timeConfig" /></td>
								<td><s:property value="#taskInfo.configer" /></td>
								<th><s:a class="glyphicon glyphicon-eye-open"
										href="javascript:void(0)" id="%{#taskInfo.id}" onclick="clickModal(this)">
										<em class="glyphicon glyphicon-eye-open"></em>
									</s:a>&nbsp;&nbsp;&nbsp;<s:a class="glyphicon glyphicon-remove"
										href="javascript:void(0)" id="%{#taskInfo.id}"
										onclick="deleteTaskInfo(this)">
										<em class="glyphicon glyphicon-remove"></em>
									</s:a></th>
							</tr>
						</s:iterator>
						<!-- <a><em class="glyphicon glyphicon-eye-open"></em></a> -->
					</tbody>
				</table>
			</div>
			<a id="modal-504349" href="#modal-container-504349" role="button" style="display: none;"
				class="btn btn-primary" data-toggle="modal">TASK中间按钮</a>

			<div class="modal fade" id="modal-container-504349" role="dialog"
				aria-labelledby="myModalLabel" aria-hidden="true"
				data-backdrop="static">
				<div class="modal-dialog">
					<div class="modal-content">
						<div class="modal-header">
							<button type="button" class="close" data-dismiss="modal"
								aria-hidden="true">×</button>
							<h4 class="modal-title" id="myModalLabel">TASK运行信息</h4>
						</div>
						<div class="modal-body">
							<form class="form-horizontal" role="form" id=""
								action="" methdo="POST">
								<div class="form-group">
									<label for="inputEmail3" class="col-sm-3 control-label">TASK名称</label>
									<div class="col-sm-8">
										<input class="form-control" id="d_taskName" type="email" readonly="readonly"/>
									</div>
								</div>
								<div class="form-group">
									<label for="inputEmail3" class="col-sm-3 control-label">时间配置</label>
									<div class="col-sm-6">
										<input class="form-control" id="d_timeConfig" type="email" readonly="readonly"/>
									</div>
								</div>
								<div class="form-group">
									<label for="inputEmail3" class="col-sm-3 control-label">上次运行批次</label>
									<div class="col-sm-6">
										<input class="form-control" id="d_lastBatchNumber" type="email" readonly="readonly"/>
									</div>
									<div class="col-sm-3">
										<a id="modal-504349" role="button"	class="btn btn-primary">下载报告</a>
									</div>
								</div>
								<div class="form-group">
									<label for="inputEmail3" class="col-sm-3 control-label">上次运行时间</label>
									<div class="col-sm-5">
										<input class="form-control" id="d_startTime" type="email" readonly="readonly" />
									</div>
								</div>
								<div class="form-group">
									<label for="inputPassword3" class="col-sm-3 control-label">邮件发送</label>
									<div class="col-sm-8">
										<textarea class="form-control" rows="3" id="d_mailTo" spellcheck="false" readonly="readonly"></textarea>
									</div>
								</div>
								<div class="form-group">
									<label for="inputPassword3" class="col-sm-3 control-label">描述</label>
									<div class="col-sm-8">
										<textarea class="form-control" rows="3" id="d_description" spellcheck="false" readonly="readonly"></textarea>
									</div>
								</div>
								<div class="form-group">
									<label for="inputPassword3" class="col-sm-3 control-label">包含用例</label>
									<div class="col-sm-8">
										<textarea class="form-control" rows="3" id="d_contains" spellcheck="false" readonly="readonly"></textarea>
									</div>
								</div>
						</div>
						<div class="modal-footer">
							<button type="submit" class="btn btn-primary" id=""
								data-dismiss="modal">关闭</button>
						</div>
						</form>
					</div>
				</div>
			</div>
		</div>
	</div>
</body>
</html>